#
# Copyright © 2021 深圳百问网科技有限公司 All Rights Reserved.
# https://www.100ask.net
# https://shop502068889.taobao.com/
#
# SPDX-License-Identifier: BSD-3-Clause
#

"""
接线
    VCC  -----  3v3
    GND  -----  GND
    SCK  -----  33
    MOSI -----  14
    MISO -----  13
    CS   -----  32
"""

SPISCK = 33
SPIMOSI = 14
SPIMISO = 13
SPICS = 32
    
from machine import Pin, SPI
import machine, sdcard, os

def sdtest():
    #spi = machine.SPI(1)
    spi = SPI(1, baudrate=10000000, polarity=0, phase=0, sck=Pin(SPISCK), mosi=Pin(SPIMOSI), miso=Pin(SPIMISO))
    spi.init()  # Ensure right baudrate
    sd = sdcard.SDCard(spi, Pin(SPICS))  # SPI and CS pin
    vfs = os.VfsFat(sd)
    os.mount(vfs, "/fc")
    print("Filesystem check")
    print(os.listdir("/fc"))

sdtest()
